# -*- coding: utf-8 -*-
'''
author:Cooper
date:2012.5.1
评价API
taobao.traderates.get
'''

from TopAPI.lib import *
import json

class traderates():
	'''
	搜索评价信息
	session:required
	'''
	api='taobao.traderates.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,format='json',
		rate_type='get',role='seller',
		result=None,page_no=None,page_size=None,
		start_date=None,end_date=None,
		tid=None,use_has_next=None):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		d['fields']='valid_score,tid,oid,role,nick,\
		result,created,rated_nick,item_title,item_price,\
		content,reply'
		url=getURL(d)
		return getRes(url)
	def parseItem(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return parseJsonField(j,'trade_rates')
	pass

def main():
	pass

if __name__=='__main__':
	main()
	pass
